package cn.Y_Qiu.user.controller;


import cn.Y_Qiu.basic.exception.BusinessException;
import cn.Y_Qiu.basic.util.Ajaxresult;
import cn.Y_Qiu.user.service.IVerifycodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {
    @Autowired
    private IVerifycodeService verifycodeService;

    @RequestMapping("/smsCode")
    public Ajaxresult sendverifycode(@RequestBody Map<String,String> param){
        String phone = param.get("phone");
        try {
            verifycodeService.checkverifycode(param);
            return Ajaxresult.me();
        } catch (BusinessException b){
            return Ajaxresult.me().setMessage(b.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return Ajaxresult.me().setMessage("系统繁忙稍后再试");
        }

    }

}
